<!-- addEditRole.html 2017-08-08 16:53:49-->
#@HplusLayout()
#define css()
<link href="#(res_path)/hplus/css/plugins/ztree/metroStyle/metroStyle.css" rel="stylesheet">
#end
#define content()
<div style="padding:10px;height: 100%">
	<form method="post" class="form-horizontal required-validate" action="saveRole" novalidate="novalidate" onsubmit="return validateCallback(this,listDialogAjaxDone)">
		<input type="hidden" name="authRole.id" value="#(authRole.id)"/>
		<input type="hidden" name="authRole.rights" value="#(authRole.rights)"/>
		<div class="form-group">
	  	<label class="col-xs-3 control-label">权限：</label>
	      <div class="col-xs-8">
	      	<input type="hidden" name="authRole.rights" value="#(authRole.rights)"/>
	      	<div class="ztree" id="ztree">
	      </div>
	    </div>
	  </div>
		<div class="form-group">
			<div class="col-xs-8 col-xs-offset-3">
				<button type="submit" class="btn btn-primary">保存</button>
			</div>
		</div>
	</form>
</div>
#end
#define js()
<script src="#(res_path)/hplus/js/plugins/validate/jquery.validate.min.js"></script>
<script src="#(res_path)/hplus/js/plugins/validate/messages_zh.min.js"></script>
<script src="#(res_path)/hplus/js/plugins/ztree/jquery.ztree.all.min.js"></script>
#end
#define jsFunction()
<script>
	var zNodes = #(rightsJSON??"[]");
	var setting = {
			check:{
				enable:true
			},
			callback:{
				onCheck:function(event,treeId,treeNode){
					var treeObj = $.fn.zTree.getZTreeObj("ztree");
					var nodes = treeObj.getCheckedNodes(true);
					var str = "";
					$.each(nodes,function(index,item){
						str = str + item.rights+",";
					});
					if(str!=""){
						str = ","+str;
					}
					$("input[name='authRole.rights']").val(str);
				}
			}
	};
	$(function(){
		$.fn.zTree.init($("#ztree"), setting, zNodes);
	});
</script>
#end
